<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      Running a Subversion Server
    </title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="blfs" id="blfs-2020-04-02">
    <div class="navheader">
      <h4>
        Beyond Linux<sup>�</sup> From Scratch <span class="phrase">(System
        V</span> Edition) - Version 2020-04-02
      </h4>
      <h3>
        Chapter&nbsp;13.&nbsp;Programming
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="subversion.html" title=
          "Subversion-1.13.0">Prev</a>
          <p>
            Subversion-1.13.0
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="swig.html" title="SWIG-4.0.1">Next</a>
          <p>
            SWIG-4.0.1
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="prog.html" title=
          "Chapter&nbsp;13.&nbsp;Programming">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="svnserver" name="svnserver"></a>Running a Subversion Server
      </h1>
      <div class="package" lang="en" xml:lang="en">
        <h2 class="sect2">
          Running a Subversion Server
        </h2>
        <p>
          This section will describe how to set up, administer and secure a
          <span class="application">Subversion</span> server.
        </p>
        <h3>
          Subversion Server Dependencies
        </h3>
        <h4>
          Required
        </h4>
        <p class="required">
          <a class="xref" href="subversion.html" title=
          "Subversion-1.13.0">Subversion-1.13.0</a> and <a class="xref" href=
          "../postlfs/openssh.html" title="OpenSSH-8.2p1">OpenSSH-8.2p1</a>
        </p>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          Setting up a Subversion Server.
        </h2>
        <p>
          The following instructions will install a <span class=
          "application">Subversion</span> server, which will be set up to use
          <span class="application">OpenSSH</span> as the secure remote
          access method, with <span class=
          "command"><strong>svnserve</strong></span> available for anonymous
          access.
        </p>
        <p>
          Configuration of the <span class="application">Subversion</span>
          server consists of the following steps:
        </p>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3"></h3>
          <h4 class="title">
            <a id="idm140006443576480" name="idm140006443576480"></a>1. Setup
            Users, Groups, and Permissions
          </h4>
          <p>
            You'll need to be user <code class="systemitem">root</code> for
            the initial portion of configuration. Create the <code class=
            "systemitem">svn</code> user and group with the following
            commands:
          </p>
          <pre class="root">
<kbd class="command">groupadd -g 56 svn &amp;&amp;
useradd -c "SVN Owner" -d /home/svn -m -g svn -s /bin/false -u 56 svn</kbd>
</pre>
          <p>
            If you plan to have multiple repositories, you should have a
            group dedicated to each repository for ease of administration.
            Create the <code class="systemitem">svntest</code> group for the
            test repository and add the <code class="systemitem">svn</code>
            user to that group with the following commands:
          </p>
          <pre class="root">
<kbd class="command">groupadd -g 57 svntest &amp;&amp;
usermod -G svntest -a svn</kbd>
</pre>
          <p>
            Additionally you should set <span class="command"><strong>umask
            002</strong></span> while working with a repository so that all
            new files will be writable by owner and group. This is made
            mandatory by creating a wrapper script for <span class=
            "command"><strong>svn</strong></span> and <span class=
            "command"><strong>svnserve</strong></span>:
          </p>
          <pre class="root">
<kbd class="command">mv /usr/bin/svn /usr/bin/svn.orig &amp;&amp;
mv /usr/bin/svnserve /usr/bin/svnserve.orig &amp;&amp;
cat &gt;&gt; /usr/bin/svn &lt;&lt; "EOF"
<code class="literal">#!/bin/sh
umask 002
/usr/bin/svn.orig "$@"</code>
EOF
cat &gt;&gt; /usr/bin/svnserve &lt;&lt; "EOF"
<code class="literal">#!/bin/sh
umask 002
/usr/bin/svnserve.orig "$@"</code>
EOF
chmod 0755 /usr/bin/svn{,serve}</kbd>
</pre>
          <div class="admon note">
            <img alt="[Note]" src="../images/note.png" />
            <h3>
              Note
            </h3>
            <p>
              If you use <span class="application">Apache</span> for working
              with the repository over HTTP, even for anonymous access, you
              should wrap <span class=
              "command"><strong>/usr/sbin/httpd</strong></span> in a similar
              script.
            </p>
          </div>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3"></h3>
          <h4 class="title">
            <a id="idm140006443559280" name="idm140006443559280"></a>2.
            Create a Subversion repository.
          </h4>
          <p>
            There are several ways to set up a subversion repository. It is
            recommended to have a look at the <a class="ulink" href=
            "http://svnbook.red-bean.com/nightly/en/svn.reposadmin.html">SVN
            Book</a> corresponding chapter. A basic repository can be set up
            with the instructions below.
          </p>
          <p>
            Create a new <span class="application">Subversion</span>
            repository with the following commands (as the <code class=
            "systemitem">root</code> user):
          </p>
          <pre class="root">
<kbd class="command">install -v -m 0755 -d /srv/svn &amp;&amp;
install -v -m 0755 -o svn -g svn -d /srv/svn/repositories &amp;&amp;
svnadmin create /srv/svn/repositories/svntest</kbd>
</pre>
          <p>
            Now that the repository is created, it should be populated with
            something useful. You'll need to have a predefined directory
            layout set up exactly as you want your repository to look. For
            example, here is a sample BLFS layout setup with a root of
            <code class="filename">svntest/</code>. You'll need to setup a
            directory tree similar to the following:
          </p>
          <pre class="screen">
<code class="literal">svntest/            # The name of the repository
   trunk/           # Contains the existing source tree
      BOOK/
      bootscripts/
      edguide/
      patches/
      scripts/
   branches/        # Needed for additional branches
   tags/            # Needed for tagging release points</code>
</pre>
          <p>
            Once you've created your directory layout as shown above, you are
            ready to do the initial import:
          </p>
          <pre class="root">
<kbd class="command">svn import -m "Initial import." \
    <em class=
"replaceable"><code>&lt;/path/to/source/tree&gt;</code></em>      \
    file:///srv/svn/repositories/svntest</kbd>
</pre>
          <p>
            Now change owner and group information on the repository, and add
            an unprivileged user to the <code class="systemitem">svn</code>
            and <code class="systemitem">svntest</code> groups:
          </p>
          <pre class="root">
<kbd class=
"command">chown -R svn:svntest /srv/svn/repositories/svntest    &amp;&amp;
chmod -R g+w         /srv/svn/repositories/svntest    &amp;&amp;
chmod g+s            /srv/svn/repositories/svntest/db &amp;&amp;
usermod -G svn,svntest -a <em class=
"replaceable"><code>&lt;username&gt;</code></em></kbd>
</pre>
          <p>
            <code class="systemitem">svntest</code> is the group assigned to
            the svntest repository. As mentioned earlier, this eases
            administration of multiple repositories when using <span class=
            "application">OpenSSH</span> for authentication. Going forward,
            you'll need to add your unprivileged user, and any additional
            users that you wish to have write access to the repository, to
            the <code class="systemitem">svn</code> and <code class=
            "systemitem">svntest</code> groups.
          </p>
          <p>
            In addition, you'll notice that the new repository's <code class=
            "filename">db</code> directory is set-groupID. If the reasoning
            is not immediately obvious, when using any external
            authentication method (such as <span class=
            "command"><strong>ssh</strong></span>), the sticky bit is set so
            that all new files will be owned by the user, but group of
            <code class="systemitem">svntest</code>. Anyone in the
            <code class="systemitem">svntest</code> group can create files,
            but still give the entire group write access to those files. This
            avoids locking out other users from the repository.
          </p>
          <p>
            Now, return to an unprivileged user account, and take a look at
            the new repository using <span class=
            "command"><strong>svnlook</strong></span>:
          </p>
          <pre class="userinput">
<kbd class="command">svnlook tree /srv/svn/repositories/svntest/</kbd>
</pre>
          <div class="admon note">
            <img alt="[Note]" src="../images/note.png" />
            <h3>
              Note
            </h3>
            <p>
              You may need to log out and back in again to refresh your group
              memberships. <span class="command"><strong>su <em class=
              "replaceable"><code>&lt;username&gt;</code></em></strong></span>
              should work as well.
            </p>
          </div>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3"></h3>
          <h4 class="title">
            <a id="idm140006443530928" name="idm140006443530928"></a>3.
            Configure the Server
          </h4>
          <p>
            As mentioned previously, these instructions will configure the
            server to use only <span class=
            "command"><strong>ssh</strong></span> for write access to the
            repository and to provide anonymous access using <span class=
            "command"><strong>svnserve</strong></span>. There are several
            other ways to provide access to the repository. These additional
            configurations are best explained at <a class="ulink" href=
            "http://svnbook.red-bean.com/">http://svnbook.red-bean.com/</a>.
          </p>
          <p>
            Access configuration needs to be done for each repository. Create
            the <code class="filename">svnserve.conf</code> file for the
            svntest repository using the following commands:
          </p>
          <pre class="root">
<kbd class="command">cp /srv/svn/repositories/svntest/conf/svnserve.conf \
   /srv/svn/repositories/svntest/conf/svnserve.conf.default &amp;&amp;

cat &gt; /srv/svn/repositories/svntest/conf/svnserve.conf &lt;&lt; "EOF"
<code class="literal">[general]
anon-access = read
auth-access = write</code>
EOF</kbd>
</pre>
          <p>
            There is not a lot to the configuration file at all. You'll
            notice that only the general section is required. Take a look at
            the <code class="filename">svnserve.conf.default</code> file for
            information on using <span class=
            "command"><strong>svnserve</strong></span>'s built-in
            authentication method.
          </p>
        </div>
        <div class="sect3" lang="en" xml:lang="en">
          <h3 class="sect3">
            <a id="svnserver-init" name="svnserver-init"></a>
          </h3>
          <h4 class="title">
            <a id="svnserver-init" name="svnserver-init"></a>4. Starting the
            Server
          </h4>
          <p>
            To start the server at boot time, install the svn bootscript
            included in the <a class="xref" href=
            "../introduction/bootscripts.html" title=
            "BLFS Boot Scripts">blfs-bootscripts-20191204</a> package:
          </p>
          <pre class="root">
<kbd class="command">make install-svn</kbd>
</pre>
        </div>
      </div>
      <p class="updated">
        Last updated on 2020-03-12 04:24:44 -0500
      </p>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="subversion.html" title=
          "Subversion-1.13.0">Prev</a>
          <p>
            Subversion-1.13.0
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="swig.html" title="SWIG-4.0.1">Next</a>
          <p>
            SWIG-4.0.1
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="prog.html" title=
          "Chapter&nbsp;13.&nbsp;Programming">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 2020-04-02">
          Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
